package com.deepclassifieds.webapi.resources;

import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;
import javax.xml.bind.JAXBElement;

import com.deepclassifieds.daas.api.xsd.ObjectFactory;
import com.deepclassifieds.daas.api.xsd.Shard;
import com.deepclassifieds.daas.api.xsd.Shards;
import com.sun.jersey.spi.resource.Singleton;

@Singleton
@Path(value = "/daas")
public class Daas {
	
	private static final ObjectFactory objectFactory = new ObjectFactory();

	@GET
    @Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
    @Path(value = "/shards")
	public synchronized JAXBElement<Shards> getShards() {
		Shards shards = new Shards();
		for(int i = 0; i < 10; ++i) {
			Shard shard = new Shard();
			shard.setNumber(i);
			shards.getShard().add(shard);
		}
        return objectFactory.createShards(shards);
    }

}
